<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="./models/Http.js"></script>
</head>

<body>
    <div id="app">
        <div v-for="(item,index) of movies">
            <p>{{index | handleTitle}}</p>
        </div>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                movies: {}
            },
            async mounted() {
                // MovieHttp.getMovie("top250").then(res=>{
                //     console.log(res.data);
                // })
                let movies = {}
                var https = ["top250", "inTheaters", "comingSoon"];
                for (let url of https) {
                    let result = await MovieHttp.getMovie(url);
                    console.log(result.data);
                    movies[url] = result.data.res;
                }
                this.movies = movies;
            },
            filters: {
                handleTitle(val) {
                    console.log(val)
                    if (val == "inTheaters") {
                        return "正在热映"
                    } else if (val == "comingSoon") {
                        return "即将上映"
                    }
                    return val;
                }
            }
            /* 
            movies:{
                top250:[result.data.res]
                inTheaters:[...],
                comingSoon:[....]
            }
             */
        })
    </script>
</body>

</html>